finding degrees of polynomials